#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>

struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
};

bool isSameTree(struct TreeNode *p, struct TreeNode *q)
{
    if (p == NULL && q == NULL) {
        return true;
    } else if (p != NULL && q != NULL && p->val == q->val) {
        return isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
    } else {
        return false;
    }
}

int main(int argc, char const *argv[])
{
    int a[] = { 0, -5 };
    int b[] = { 0, -8 };
    struct TreeNode al = {a[1], NULL, NULL};
    struct TreeNode bl = {b[1], NULL, NULL};
    struct TreeNode p = {a[0], &al, NULL};
    struct TreeNode q = {b[0], &bl, NULL};
    printf("%d\n", isSameTree(&p, &q));

    return 0;
}